'use strict';

/* Directives */

// directive for dependency injection, creates html element that gets injected into index.html with charts
angular.module("app.directives", []).directive("barsChart", function($parse) {
    var object = {
        restrict: "E",
        replace: false,
        scope: { data: "=chartData" },
        link: function(scope, element, attrs) {
            var chart = d3.select(element[0]);
            chart.append("div").attr("class", "chart")
                .selectAll("div")
                .data(scope.data).enter().append("div")
                .transition().ease("elastic")
                .style("width", function(d) { return d + "%"; })
                .text(function(d) { return d; })
        }
    };
    return object;
});